package com.bridgeintelligent.tag.webserver.dim.mgmt.service.item;

import com.bridgeintelligent.tag.webserver.dim.mgmt.api.DimRep;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * Created by JackCheung on 2019/9/10 3:51 AM.
 */
@RestController
@Api(tags = "标签项管理")
@RequestMapping("api/dimItem")
public class DimItemController {

    private IDimItemService iDimItemService;

    public DimItemController(IDimItemService iDimItemService) {
        this.iDimItemService = iDimItemService;
    }

    @ApiOperation(value = "查看该标签下的所有标签醒目", notes = "标签项管理")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", name = "dimId", value = "标签ID", required = true)})
    @GetMapping("/list")
    public DimRep list(String dimId) {
        return iDimItemService.list(dimId);
    }

    @ApiOperation(value = "删除某个标签项", notes = "标签项管理")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", name = "id", value = "标签项ID", required = true)})
    @DeleteMapping("/del")
    public DimRep del(String id) {
        return iDimItemService.del(id);
    }

    @ApiOperation(value = "增加某个标签项", notes = "标签项管理")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "dimId", value = "标签ID", required = true),
            @ApiImplicitParam(paramType = "query", name = "itemNo", value = "标签项标示", required = true),
            @ApiImplicitParam(paramType = "query", name = "itemName", value = "标签项名称", required = true),
    })
    @PostMapping("/add")
    public DimRep add(String dimId, String itemNo, String itemName) {
        return iDimItemService.add(dimId, itemNo, itemName);
    }

    @ApiOperation(value = "修改某个标签项", notes = "标签项管理")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "标签项", required = true),
            @ApiImplicitParam(paramType = "query", name = "dimId", value = "标签ID"),
            @ApiImplicitParam(paramType = "query", name = "itemNo", value = "标签项标示"),
            @ApiImplicitParam(paramType = "query", name = "definition", value = "描述"),
    })
    @PostMapping("/update")
    public DimRep update(@RequestBody String id, String dimId, String itemNo, String definition) {
        return iDimItemService.update(id, dimId, itemNo, definition);
    }
}
